import 'package:flutter/material.dart';
import 'package:flutter_frame/app/modules/home/home/controller.dart';
import 'package:get/get.dart';

class HomePage extends StatelessWidget {
  HomePage({Key? key}) : super(key: key);

  final controller = Get.put(HomeController());

  @override
  Widget build(BuildContext context) {
    return GetBuilder(builder: (HomeController controller) {
      return WillPopScope(
          child: Scaffold(
            body: IndexedStack(
              index: controller.index,
              children: controller.myTabs,
            ),
            bottomNavigationBar: NavigationBar(
                    selectedIndex: controller.index,
                    onDestinationSelected: (index) {
                      controller.changeTab(index);
                    },
                    destinations: const [
                      NavigationDestination(icon: Icon(Icons.home), label: '首页'),
                      NavigationDestination(icon: Icon(Icons.web), label: '网页'),
                    ],
                  ),
          ),
          onWillPop: () async {
            return controller.onWillPop();
          });
    });
  }
}
